<!DOCTYPE html>
<html>
<!--
Copyright 2010 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
  <title>goog.silverlight.ClipboardButton</title>
  <meta charset="utf-8">
  <script src="../base.js"></script>
<script src="../../../third_party/closure/goog/deps.js"></script>
  <script>
    goog.require('goog.dom');
    goog.require('goog.silverlight.CopyButton');
    goog.require('goog.silverlight.PasteButton');

  </script>
  <link rel="stylesheet" href="css/demo.css">
  <style>
  </style>
</head>
<body>
  <h1>goog.silverlight.ClipboardButton</h1>

  <div>Click 'Paste' to alert the contents on your clipboard:</div>
  <div id='pasteButton'></div>

  <p/>
  <div>Click 'Copy' to put the contents of
      this textarea on your clipboard:</div>
  <div id='copyButton'></div>
  <textarea id='textarea'>
  Content to copy
  </textarea>

  <script>

  var $ = goog.dom.$;
 var DIR = '../../../third_party/closure/goog/';

  var XAP = DIR + 'silverlight/' +
      'clipboardbuttonxap/Bin/Release/ClosureClipboardButton.xap';

  if (goog.silverlight.ClipboardButton.hasClipboardAccess()) {
    var pasteButton = new goog.silverlight.PasteButton(XAP);
    pasteButton.render($('pasteButton'));
    goog.events.listen(
        pasteButton,
        goog.silverlight.ClipboardEventType.PASTE,
        function(e) {
          alert(e.getData());
        });

    var copyButton = new goog.silverlight.CopyButton(XAP, 'Copy Textarea');
    copyButton.render($('copyButton'));
    goog.events.listen(
        copyButton,
        goog.silverlight.ClipboardEventType.COPY,
        function(e) {
          e.setData($('textarea').value);
        });
  } else {
    document.write(
        '<b>No native clipboard access--demo will not function</b>');
  }

  </script>
</body>
</html>
